#!/usr/bin/env python
# coding=utf-8
from cffi import FFI
from inspect import getmembers
from pprint import pprint
import json

ffi = FFI()
ffi.cdef(open('pffi.h').read())
lib = ffi.dlopen("../../../target/release/libpoker_ffi.dylib")

data_round = open('round_bid.json').read()
data_table = open('table.json').read()
srn_py = ffi.new("rs_SpadesRound *", json.loads(data_round))
stn_py = ffi.new("rs_SpadesTable *", json.loads(data_table))
print(f"mode: { stn_py.mode} final_score:{stn_py.final_score} limit_bag:{stn_py.limit_bag} joker:{stn_py.joker}")
print("bid=", lib.rs_SpadesAi_bid(srn_py, stn_py))

data_round = open('round.json').read()
data_table = open('table.json').read()
srn_py = ffi.new("rs_SpadesRound *", json.loads(data_round))
stn_py = ffi.new("rs_SpadesTable *", json.loads(data_table))
print("play=", lib.rs_SpadesAi_play(srn_py, stn_py))

